/**
 * MP Software.
 */
package service;

import helpers.ElectronicIdConstant;

import java.math.BigDecimal;
import java.util.List;

import javax.inject.Inject;

import models.Deduction;
import models.Payment;
import models.Rate;
import play.modules.guice.InjectSupport;
import service.calculator.aristocrat.AristocratPayrollCalculator;
import service.calculator.bagnetified.sanmateo.BagnetifiedSanMateoPayrollCalculatorImpl;
import service.calculator.bonchon.BonchonPayrollCalculator;
import service.calculator.bonchon.baguio.BonchonBaguioPayrollCalculatorImpl;
import service.calculator.bonchon.batangas.BonchonBatangasPayrollCalculatorImpl;
import service.calculator.bonchon.lumina.BonchonLuminaPayrollCalculatorImpl;
import service.calculator.bonchon.marquee.BonchonMarqueePayrollCalculatorImpl;
import service.calculator.bonchon.paseo.BonchonPaseoPayrollCalculatorImpl;
import service.calculator.crystalite.CrystalitePayrollCalculatorImpl;
import service.calculator.crystalite.laguna.CrystaliteLagunaPayrollCalculatorImpl;
import service.calculator.jeron.JeronPayrollCalculatorImpl;
import service.calculator.sonic.SonicPayrollCalculatorImpl;
import service.calculator.sonic.two.Sonic2PayrollCalculatorImpl;

/**
 * @author Jeremiah John M. Macariola
 * 
 */
@InjectSupport
public class PayrollCalculatorFacadeImpl implements PayrollCalculatorFacade {

	@Inject
	private static BonchonPayrollCalculator bonchonPayrollCalculator;

	@Inject
	private static BonchonBatangasPayrollCalculatorImpl bonchonBatangasPayrollCalculator;

	@Inject
	private static BonchonPaseoPayrollCalculatorImpl bonchonPaseoPayrollCalculator;

	@Inject
	private static BonchonBaguioPayrollCalculatorImpl bonchonBaguioPayrollCalculator;

	@Inject
	private static BonchonMarqueePayrollCalculatorImpl bonchonMarqueePayrollCalculator;

	@Inject
	private static BonchonLuminaPayrollCalculatorImpl bonchonLuminaPayrollCalculator;

	@Inject
	private static AristocratPayrollCalculator aristocratPayrollCalculator;

	@Inject
	private static CrystalitePayrollCalculatorImpl crystalitePayrollCalculator;

	@Inject
	private static CrystaliteLagunaPayrollCalculatorImpl crystaliteLagunaPayrollCalculator;

	@Inject
	private static JeronPayrollCalculatorImpl jeronPayrollCalculator;

	@Inject
	private static SonicPayrollCalculatorImpl sonicPayrollCalculator;

	@Inject
	private static Sonic2PayrollCalculatorImpl sonic2PayrollCalculator;

	@Inject
	private static BagnetifiedSanMateoPayrollCalculatorImpl bagnetifiedSanMateoPayrollCalculatorImpl;

	public CalculationResult calculate(String electronicId, Rate rate,
			List<Payment> payments, List<Deduction> deductions) {
		PayrollCalculator payrollCalculator = switchPayrollCalculator(electronicId);
		return payrollCalculator.calculate(rate, payments, deductions);
	}

	public BigDecimal calculatePayment(String electronicId, Rate rate,
			Payment payment) {
		PayrollCalculator payrollCalculator = switchPayrollCalculator(electronicId);
		return payrollCalculator.calculatePayment(rate, payment);
	}

	private PayrollCalculator switchPayrollCalculator(String electronicId) {
		PayrollCalculator payrollCalculator = null;
		if (ElectronicIdConstant.BONCHON.equals(electronicId)) {
			payrollCalculator = bonchonPayrollCalculator;
		} else if (ElectronicIdConstant.BONCHON_BATANGAS.equals(electronicId)) {
			payrollCalculator = bonchonBatangasPayrollCalculator;
		} else if (ElectronicIdConstant.BONCHON_PASEO.equals(electronicId)) {
			payrollCalculator = bonchonPaseoPayrollCalculator;
		} else if (ElectronicIdConstant.BONCHON_BAGUIO.equals(electronicId)) {
			payrollCalculator = bonchonBaguioPayrollCalculator;
		} else if (ElectronicIdConstant.BONCHON_MARQUEE.equals(electronicId)) {
			payrollCalculator = bonchonMarqueePayrollCalculator;
		} else if (ElectronicIdConstant.BONCHON_LUMINA.equals(electronicId)) {
			payrollCalculator = bonchonLuminaPayrollCalculator;
		} else if (ElectronicIdConstant.ARISTOCRAT.equals(electronicId)) {
			payrollCalculator = aristocratPayrollCalculator;
		} else if (ElectronicIdConstant.CRYSTALITE.equals(electronicId)) {
			payrollCalculator = crystalitePayrollCalculator;
		} else if (ElectronicIdConstant.JERON.equals(electronicId)) {
			payrollCalculator = jeronPayrollCalculator;
		} else if (ElectronicIdConstant.CRYSTALITE_LAGUNA.equals(electronicId)) {
			payrollCalculator = crystaliteLagunaPayrollCalculator;
		} else if (ElectronicIdConstant.SONIC.equals(electronicId)) {
			payrollCalculator = sonicPayrollCalculator;
		} else if (ElectronicIdConstant.SONIC_2.equals(electronicId)) {
			payrollCalculator = sonic2PayrollCalculator;
		} else if (ElectronicIdConstant.BAGNETIFIED_SANMATEO.equals(electronicId)) {
			payrollCalculator = bagnetifiedSanMateoPayrollCalculatorImpl;
		}

		return payrollCalculator;
	}

}
